<script setup lang="ts">
import { computed } from "vue"
interface Props {
  name: string;
  className?: string;
}
const props = withDefaults(defineProps<Props>(), {
  name: '',
  className: ''
})

const iconName = computed(() => {
  const name = props.name
  return `#icon-${name}`;
})

const svgClass = computed(() => {
  const className = props.className
  if (className) {
    return "svg-icon " + className
  } else {
    return "svg-icon"
  }
})
</script>

<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName"/>
  </svg>
</template>

<style lang="scss" scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: middle;
  fill: #333;
  overflow: hidden;

  &:focus {
    outline: none;
  }
}
</style>